<template>
  <div class="box">
    <div class="top">
      <div class="userAvter">
        <van-image
          :src="userInfo.avatar"
          height="60px"
          round
          width="60px"
        />
      </div>
      <div class="userName">
        用户昵称：{{ userInfo.nikeName }}
      </div>
      <div class="personality">
        个性签名：{{ userInfo.nikeName }}
      </div>

      <div class="userComm">
        <div>
          <div><span>论坛：</span>{{ userInfo.MyCommentCount }}</div>
          <div><span>获赞：</span>{{ userInfo.beLikedNumber }}</div>
        </div>
      </div>
    </div>
    <div class="bottom">
      <div class="li" @click="goComment">
        <div><img src="@/assets/images/书本3.png" style="height: 20px;width: 20px"></div>
        <div>我的帖子</div>
        <div>
          {{ userInfo.forumSize }}
          <van-icon name="arrow"/>
        </div>
      </div>
      <div class="li">
        <div><img src="@/assets/images/更多.png" style="height: 20px;width: 20px"></div>
        <div>我的错题本</div>
        <div>
          {{ userInfo.errorTestPaperCount }}
          <van-icon name="arrow"/>
        </div>
      </div>
      <div class="li" @click="goReviewed">
        <div><img src="@/assets/images/收藏.png" style="height: 20px;width: 20px"></div>
        <div>被阅的卷子</div>
        <div>
          {{ userInfo.jobTestPaperCount }}
          <van-icon name="arrow"/>
        </div>
      </div>
      <div class="li" @click="goMyComment">
        <div><img src="@/assets/images/评论.png" style="height: 20px;width: 20px"></div>
        <div>我的评论</div>
        <div>
          {{ userInfo.MyCommentCount }}
          <van-icon name="arrow"/>
        </div>
      </div>
      <div class="li" @click="myDoLike">
        <div><img src="@/assets/images/点赞.png" style="height: 20px;width: 20px"></div>
        <div>我的点赞</div>
        <div>
          {{ userInfo.MyUpvoteCount }}
          <van-icon name="arrow"/>
        </div>
      </div>
    </div>

  </div>
</template>
<script>
import {mapGetters} from "vuex";
import {getHomePageInfo} from '@/api/homePgae/index'

export default {
  data() {
    return {
      userInfo: {}
    }
  },
  computed: {
    ...mapGetters(["name", 'userId']),
  },
  mounted() {
    this.getUserInfo()
  }

  ,
  methods: {
    getUserInfo() {
      getHomePageInfo({userId: this.userId}).then(res => {

        this.userInfo = res

      })
    },
    goComment() {
      this.$router.push({
        path: '/community/community/index',
        query: {userId: this.userId,type:'vote'}
      })
    },
    goMyComment() {
      this.$router.push({path: '/personalHomepage/personalHomepage/components/myComment?userId=' + this.userId})
    }
    ,
    myDoLike() {
      this.$router.push({path: '/community/community/index?type=vote'})
    }
    ,
    goReviewed() {
      this.$router.push({path: '/markingPapers/Q&Aarea/Reviewed'})
    }
  }
}
</script>

<style lang="scss" scoped>
.box {
  height: 100%;
  overflow: auto;
  background-color: #f1f3f8;

  .top {
    height: 150px;
    background-color: #4095e5;
    margin-bottom: 20px;
    //overflow: hidden;
    //position: relative;

    .userAvter {
      display: flex;
      align-items: center;
      justify-content: center;
      padding-top: 10px;
    }

    .userName {
      text-align: center;
      margin-top: 10px;
    }

    .userComm {
      background-color: red;
      position: relative;

      > div {
        position: absolute;
        top: 10px;
        margin: 0 auto;
        background-color: white;
        display: flex;
        width: 60%;
        left: 20%;
        height: 40px;
        align-items: center;
        justify-content: space-between;
        padding: 0 20px;
        border-radius: 10px;
        line-height: 40px;
        border: 1px solid #e5e5e5;

      }
    }

    .personality {
      font-size: 12px;
      padding: 0 10px;
    }

  }

  .bottom {
    min-height: fit-content;
    background-color: white;
    margin-top: 25px;

    .li {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 10px 20px;
      border-bottom: 1px solid #e5e5e5;

      > div:nth-of-type(1) {
        text-align: left;
      }

      > div:nth-of-type(2) {
        width: 100px;
        text-align: center;
      }

      > div:nth-of-type(3) {
        text-align: right;
      }

      div {
        width: 40px;
        text-align: right;
      }

    }
  }

}
</style>
